package com.situ.day6;

import java.util.Scanner;

public class StudentManager {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入学生数量：");
        int count = scanner.nextInt();
        Student[] array = new Student[count];
        for (int i = 0; i < array.length; i++) {
            System.out.println("请输入学生id：");
            int id = scanner.nextInt();
            System.out.println("请输入学生姓名: ");
            String name = scanner.next();
            System.out.println("请输入年龄：");
            int age = scanner.nextInt();
            System.out.println("请输入性别：");
            String gender = scanner.next();
            Student student = new Student(id, name, age, gender);
            //没循环一次构造一个Student，然后放到数组里面
            array[i] = student;
        }

        for (Student student : array) {
            System.out.println(student);
        }

        while (true) {
            System.out.println("根据id查找：1");
            System.out.println("根据name查找：2");
            System.out.println("根据age查找：3");
            System.out.println("根据gender查找：4");
            System.out.println("退出：0");
            int type = scanner.nextInt();
            if (type == 0) {
                System.out.println("退出程序");
                break;
            }

            switch (type) {
                case 1:
                    System.out.println("请输入要查找的id：");
                    int id = scanner.nextInt();
                    for (Student student : array) {
                        if (id == student.getId()) {
                            System.out.println(student);
                        }
                    }
                    //没有找到任何一个符合条件的学生，打印：没有该id学生
                    break;
                case 2:
                    System.out.println("请输入要查找的name：");
                    String name = scanner.next();
                    for (Student student : array) {
                        if (name.equalsIgnoreCase(student.getName())) {
                            System.out.println(student);
                        }
                    }
                    //没有找到任何一个符合条件的学生，打印：没有该name学生
                    break;
                case 3:
                    break;
                case 4:
                    break;
                default:
                    System.out.println("default");
                    break;
            }
        }
    }
}
